package org.dreamwork.tools.simulator.connector.data;

import org.dreamwork.persistence.ISchema;
import org.dreamwork.persistence.ISchemaField;
import org.dreamwork.tools.simulator.connector.data.schema.RequestLogSchema;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;

@ISchema (RequestLogSchema.class)
public class RequestLog implements Serializable {
    @ISchemaField (name = "id", id = true)
    private String id;
    // "id", "if_id", "uri", "body", "request_time"
    @ISchemaField (name = "if_id")
    private String interfaceId;

    @ISchemaField (name = "uri")
    private String uri;

    @ISchemaField (name = "method")
    private String method;

    @ISchemaField (name = "body")
    private String body;

    @ISchemaField (name = "client")
    private String client;

    @ISchemaField (name = "request_time")
    private Date requestTime;

    public String getId () {
        return id;
    }

    public void setId (String id) {
        this.id = id;
    }

    public String getInterfaceId () {
        return interfaceId;
    }

    public void setInterfaceId (String interfaceId) {
        this.interfaceId = interfaceId;
    }

    public String getUri () {
        return uri;
    }

    public void setUri (String uri) {
        this.uri = uri;
    }

    public String getMethod () {
        return method;
    }

    public void setMethod (String method) {
        this.method = method;
    }

    public String getBody () {
        return body;
    }

    public void setBody (String body) {
        this.body = body;
    }

    public String getClient () {
        return client;
    }

    public void setClient (String client) {
        this.client = client;
    }

    public Date getRequestTime () {
        return requestTime;
    }

    public void setRequestTime (Date requestTime) {
        this.requestTime = requestTime;
    }

    @Override
    public int hashCode () {
        return id == null ? 0 : id.hashCode ();
    }

    @Override
    public boolean equals (Object obj) {
        if (obj == null) return false;
        Class<?> type = obj.getClass ();
        if (getClass () != type) return false;

        RequestLog that = (RequestLog) obj;
        return id != null && id.equals (that.id);
    }
}